###MIYO包下载pei

################自己服务器存储的历史包################
def download_url(manifest_url):
    return "itms-services://?action=download-manifest&url=" + manifest_url

def luka_manifesturl(version, debug=True):
    if debug == True:
        type = "debug"
    else:
        type = "release"
    return "https://app-distribution-1310744949.cos.ap-shanghai.myqcloud.com/luka-ios/" + type + "/" + version + "/manifest.plist"

def miyo_manifesturl(version, debug=True):
    if debug == True:
        type = "debug"
    else:
        type = "release"
    return "https://app-distribution-1310744949.cos.ap-shanghai.myqcloud.com/miyo-ios/" + type + "/" + version + "/manifest.plist"

def mimi_manifesturl(version, debug=True):
    if debug == True:
        type = "debug"
    else:
        type = "release"
    return "https://app-distribution-1310744949.cos.ap-shanghai.myqcloud.com/mimi-ios/" + type + "/" + version + "/manifest.plist"

def mowang_manifesturl(version, debug=True):
    if debug == True:
        type = "debug"
    else:
        type = "release"
    return "https://app-distribution-1310744949.cos.ap-shanghai.myqcloud.com/mostone-ios/" + type + "/" + version + "/manifest.plist"

def luka_ipaurl(version, debug=True):
    if debug == True:
        type = "debug"
    else:
        type = "release"
    return "https://app-distribution-1310744949.cos.ap-shanghai.myqcloud.com/luka-ios/" + type + "/" + version + "/LUKA.ipa"

def miyo_ipaurl(version, debug=True):
    if debug == True:
        type = "debug"
    else:
        type = "release"
    return "https://app-distribution-1310744949.cos.ap-shanghai.myqcloud.com/miyo-ios/" + type + "/" + version + "/MIYO.ipa"

def mimi_ipaurl(version, debug=True):
    if debug == True:
        type = "debug"
    else:
        type = "release"
    return "https://app-distribution-1310744949.cos.ap-shanghai.myqcloud.com/mimi-ios/" + type + "/" + version + "/MMVoice.ipa"

def luka_manifest_data(version, debug=True):
    data = {
            "items": [
                {
                    "assets": [
                        {
                            "kind": "software-package",
                            "url": luka_ipaurl(version=version, debug=debug),
                        },
                        {
                            "kind": "display-image",
                            "url": "https://app-distribution-1310744949.cos.ap-shanghai.myqcloud.com/luka-ios/fullImage.png",
                        },
                        {
                            "kind": "full-size-image",
                            "url": "https://app-distribution-1310744949.cos.ap-shanghai.myqcloud.com/luka-ios/fullImage.png",
                        }
                    ],
                    "metadata": {
                        "bundle-identifier": "com.qianmiao.tika",
                        "bundle-version": version,
                        "kind": "software",
                        "platform-identifier": "com.apple.platform.iphoneos",
                        "title": "LUKA"
                    }
                }
            ]
        }
    return data

def miyo_manifest_data(version, debug=True):
    data = {
            "items": [
                {
                    "assets": [
                        {
                            "kind": "software-package",
                            "url": miyo_ipaurl(version=version, debug=debug),
                        },
                        {
                            "kind": "display-image",
                            "url": "https://app-distribution-1310744949.cos.ap-shanghai.myqcloud.com/miyo-ios/fullImage.png",
                        },
                        {
                            "kind": "full-size-image",
                            "url": "https://app-distribution-1310744949.cos.ap-shanghai.myqcloud.com/miyo-ios/fullImage.png",
                        }
                    ],
                    "metadata": {
                        "bundle-identifier": "com.mkapp.mkvoice",
                        "bundle-version": version,
                        "kind": "software",
                        "platform-identifier": "com.apple.platform.iphoneos",
                        "title": "MIYO"
                    }
                }
            ]
        }
    return data

def miyo_ipas():
    MIYO_IPAS = [
        {"version": "v3.0.0", "date": "2024-02-18"},
        {"version": "v2.2.4", "date": "2024-01-02"},
        {"version": "v2.2.3", "date": "2023-12-13"}
    ]
    for item in MIYO_IPAS:
        debug_manifesturl = miyo_manifesturl(item["version"], debug=True)
        item["debug_url"] = download_url(debug_manifesturl)
        release_manifesturl = miyo_manifesturl(item["version"], debug=False)
        item["release_url"] = download_url(release_manifesturl)
    return MIYO_IPAS

def luka_ipas():
    LUKA_IPAS = [
        {"version": "v3.3.9", "date": "2024-02-27"},
        {"version": "v3.3.8", "date": "2024-02-04"},
        {"version": "v3.3.7", "date": "2024-01-17"},
        {"version": "v3.3.4", "date": "2023-12-29"},
        {"version": "v3.3.3", "date": "2023-12-27"},
        {"version": "v3.3.2", "date": "2023-12-21"},
        {"version": "v3.3.0", "date": "2023-12-18"},
    ]
    for item in LUKA_IPAS:
        debug_manifesturl = luka_manifesturl(item["version"], debug=True)
        item["debug_url"] = download_url(debug_manifesturl)
        release_manifesturl = luka_manifesturl(item["version"], debug=False)
        item["release_url"] = download_url(release_manifesturl)
    return LUKA_IPAS

def mimi_ipa():
    MIMI_IPAS = [
        {"version": "v3.1.1", "date": "2024-05-14"},
        {"version": "v3.1.0", "date": "2024-05-01"},
        {"version": "v3.0.9", "date": "2024-04-25"},
        {"version": "v3.0.8", "date": "2024-04-12"},
        {"version": "v1.0.0", "date": "2024-02-27"},
    ]
    for item in MIMI_IPAS:
        debug_manifesturl = mimi_manifesturl(item["version"], debug=True)
        item["debug_url"] = download_url(debug_manifesturl)
        release_manifesturl = mimi_manifesturl(item["version"], debug=False)
        item["release_url"] = download_url(release_manifesturl)
    return MIMI_IPAS

def mowang_ipas():
    MOSTONE_IPAS = [
        {"version": "v3.50.1", "date": "2024-04-19"},
        {"version": "v3.44.5", "date": "2024-03-26"},
    ]
    for item in MOSTONE_IPAS:
        debug_manifesturl = mowang_manifesturl(item["version"], debug=True)
        item["debug_url"] = download_url(debug_manifesturl)
        release_manifesturl = mowang_manifesturl(item["version"], debug=False)
        item["release_url"] = download_url(release_manifesturl)
    return MOSTONE_IPAS

def all_iaps():
    return {
        "MIYO": miyo_ipas(),
        "LUKA": luka_ipas(),
        "MIMI": mimi_ipa(),
        "MOSTONE": mowang_ipas()
    }

#########################打包机最新版本配置#########################
def shiyanshi_miyo_ipas(debug=True):
    debug_manifest = "https://moka-minifile-1309025552.cos.ap-shanghai.myqcloud.com/ios/shiyanshi/moka_manifest.plist"
    release_manifest = "https://app-distribution-1310744949.cos.ap-shanghai.myqcloud.com/miyo-ios/release/shiyanshi_manifest.plist"
    return [
        {"version": "最新", "date": "未知", "debug_url": download_url(debug_manifest), "release_url": download_url(release_manifest)},
    ]

def shiyanshi_luka_ipas(debug=True):
    debug_manifest = "https://moka-minifile-1309025552.cos.ap-shanghai.myqcloud.com/ios/shiyanshi/bb_manifest.plist"
    release_manifest = "https://app-distribution-1310744949.cos.ap-shanghai.myqcloud.com/luka-ios/release/shiyanshi_manifest.plist"
    return [
        {"version": "最新", "date": "未知", "debug_url": download_url(debug_manifest), "release_url": download_url(release_manifest)}
    ]

def shiyanshi_all_ipas():
    return {
        "MIYO": shiyanshi_miyo_ipas(),
        "LUKA": shiyanshi_luka_ipas()
    }